package com.gitee.slowcreator.http.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author zxw
 * @date 2023/1/4 下午10:09
 */
@Getter
@AllArgsConstructor
public enum RequestType {

    GET("GET"),

    POST("POST"),

    PUT("PUT"),

    DELETE("DELETE"),

    ;

    private final String type;

    public static RequestType getType(String type) {

        if (StringUtils.isBlank(type)) {
            return null;
        }

        for (RequestType value : values()) {
            if (StringUtils.equals(value.getType(), type)) {
                return value;
            }
        }

        return null;
    }
}
